<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Ads/classes/PhpFox_ComponentAdsAdd.class.php, $Author:  $ */



/** Component for adding ads
 * @version $Id: PhpFox_ComponentAdsAdd.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.ads
 *
 */
class PhpFox_Mod_Ads_ComponentAdsAdd extends BaseComponent
{
    function process()
    {
    	$oAdsService = &$this->_oModule->getService('Ads');
        $oAdsItem = &$this->_oModule->getItem('Ads');
        /* @var $oAdsItem PhpFox_Mod_Ads_ItemAds */
        $oReq = &App::getRequest();
        $oUrl = &App::getUrl();
        $oTpl = &$this->_oModule->getTemplate();
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        if (!$oSecurityService->hasStaffPerm('MENU_edit_adds'))
        {
            App::gotoUrl('admin.main');
        }

        $aAdsTypes = App::getParam('ads.types');
        if ($oReq->getAction() == 'add')
        {
            $iType = $oReq->getInt('type');
            if (array_key_exists($iType, $aAdsTypes))
            {
                $oAdsItem->aData['text'] = $oReq->get('text');
                $oAdsItem->aData['type'] = $iType;
                $iAdsId = $oAdsItem->insert();
            }
            $oAdsService->deleteCached($iType);
            App::gotoUrl('admin.extra.ads');
        }

        $oTpl->assign(array(
            'aTypes' => $aAdsTypes,
        ));
        return $oTpl->fetch('AdsAdd.html');
    }
}
?>